﻿//显示音乐面板
function btnYinYue() {
    showTool(true);
    var tools = getTools();

    var html = "";
    html += "<div class='d_z adtitle clearfix'><div class='adfl dw30'>插入音乐</div><div class='adfr adfwn dw60 adtar'><span class='d_z adbtn' data-f='yinyueqingkong()'>清除音乐</span><span class='d_z adbtn' data-f='webzifanhui()'>返回</span></div></div><div class='adnexturl addb adw100' >向下滑动加载更多音乐...</div>";

    tools.html(html);

    //加载10条
    loadYinYue(10);

    bindButtonClickEvent();
}

//音乐去确定
function yinyuequeding(id) {
    yinyueqingkong();
    //插入到顶部
    $("body").children().eq(0).before($("<audio src='http://thirdparty.gtimg.com/" + id + ".m4a?fromtag=38' autoplay='autoplay' loop='loop'/>"));
}

function yinyueqingkong() {
    hideMenu();
    $("audio").remove();
}


function loadYinYue(count) {
    showlog(count);

    var ms = "102053195,突然好想你,1383715,不再联系,22836,不是因为寂寞,7016921,贝加尔湖畔,5266731,传奇,102350727,车站,2651369,Yesterday Once More,6544888,恋人心,7109361,明天 你好,944319,那个男人,5018140,一不小心,101099682,奇妙能力歌,102388362,My Sunshine,314621,Because Of You ,3572709,滴答,4991941,当有天老去,103459,怒放的生命,390898,风吹麦浪,390898,回忆的的沙漏,577166,好久不见,659572,鸿雁,4830000,剪爱,5200503,卷珠帘,1250002,慢慢,777379,梦中的婚礼,9125077,你是我的眼,103459,怒放的生命,839925,时间都去哪儿呢,1313844,The Sound Of Silence,6589366,You Can Rely On Me,5598715,Hello You Beautiful Thing,7212480,斑马 斑马,7223790,我相信,9125077,你是我的眼,659572,鸿雁,9103820,匆匆那年,7223443,相信我,4602,朋友,4830471,阳光总在风雨后,123674,光辉岁月,410316,青花瓷,4829324,龙卷风,102698215,千里之外 ,5602949,生日快乐,4830471,阳光总在风雨后,875060,在路上,630586,婚礼进行曲".split(',');

    if (getNextUrl().length > 0) {
        for (var i = 0; i < ms.length / 2; i++) {
            if (i >= count - 10 && i < count) {
                var div = $("<div class='d_z  addb adb1gray adm1 adbr4 adh40 adbtnX' style='width:" + (getTools().width() - 10) + "' data-f='yinyuequeding(" + ms[i * 2] + ")'>" + ms[i * 2 + 1] + "</div>");

                getNextUrl().before(div);
            }
        }

        //是否显示加载更多
        if (ms.length / 2 >= count) {
            getNextUrl().attr("data-f", "loadYinYue(" + (count + 10) + ")");
        } else {
            //没有就移除
            getNextUrl().remove();
        }
    }

    //加载事件
    bindButtonClickEvent();
}

